package com.enjoy.seata.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtil {

    private static Properties properties;

    static {
        load();
    }

    public static void load() {
        try {
            InputStream inputStream = PropertiesUtil.class.getClassLoader().getResourceAsStream("jdbc.properties");
            properties = new Properties();
            properties.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getPropertyValue(String key, String defaultValue) {
        String propertyValue = properties.getProperty(key);
        return propertyValue == null ? defaultValue : propertyValue;
    }

    public static String getPropertyValue(String key) {
        return getPropertyValue(key, null);
    }

}
